#处理ffmpeg指令脚本 ffmpeg_allpush.sh
#!/bin/bash

# 定义 RTSP 源和 RTMP 目标
declare -A streams
streams=(
 ["rtsp://36.133.66.40:8554/cdtf-ZjdkOTUy"]="rtmp://192.168.28.125:1935/live/cdtf-ZjdkOTUy"
["rtsp://36.133.66.40:8554/cdtf-OWVjYTY1"]="rtmp://192.168.28.125:1935/live/cdtf-OWVjYTY1"
["rtsp://36.133.66.40:8554/cdtf-M2M3YzA5"]="rtmp://192.168.28.125:1935/live/cdtf-M2M3YzA5"
["rtsp://36.133.66.40:8554/cdtf-MjA5NDQ5"]="rtmp://192.168.28.125:1935/live/cdtf-MjA5NDQ5"
["rtsp://36.133.66.40:8554/cdtf-ODkxZDc2"]="rtmp://192.168.28.125:1935/live/cdtf-ODkxZDc2"
["rtsp://36.133.66.40:8554/cdtf-YmU5YjQ5"]="rtmp://192.168.28.125:1935/live/cdtf-YmU5YjQ5"
["rtsp://36.133.66.40:8554/cdtf-NzkzNmRm"]="rtmp://192.168.28.125:1935/live/cdtf-NzkzNmRm"
["rtsp://36.133.66.40:8554/cdtf-MDU4NWVh"]="rtmp://192.168.28.125:1935/live/cdtf-MDU4NWVh"
["rtsp://36.133.66.40:8554/cdtf-N2Q4NGNl"]="rtmp://192.168.28.125:1935/live/cdtf-N2Q4NGNl"
["rtsp://36.133.66.40:8554/cdtf-NDVlNWQw"]="rtmp://192.168.28.125:1935/live/cdtf-NDVlNWQw"
["rtsp://36.133.66.40:8554/cdtf-NTJlYjA0"]="rtmp://192.168.28.125:1935/live/cdtf-NTJlYjA0"
["rtsp://36.133.66.40:8554/cdtf-ZjhjYjMy"]="rtmp://192.168.28.125:1935/live/cdtf-ZjhjYjMy"
["rtsp://36.133.66.40:8554/cdtf-NWZhNDgy"]="rtmp://192.168.28.125:1935/live/cdtf-NWZhNDgy"
["rtsp://36.133.66.40:8554/cdtf-MTkxOGEw"]="rtmp://192.168.28.125:1935/live/cdtf-MTkxOGEw"
["rtsp://36.133.66.40:8554/cdtf-N2NmNmNk"]="rtmp://192.168.28.125:1935/live/cdtf-N2NmNmNk"
["rtsp://36.133.66.40:8554/cdtf-N2FjYzA1"]="rtmp://192.168.28.125:1935/live/cdtf-N2FjYzA1"
["rtsp://36.133.66.40:8554/cdtf-Y2EzMDE0"]="rtmp://192.168.28.125:1935/live/cdtf-Y2EzMDE0"
["rtsp://36.133.66.40:8554/cdtf-MTNhYmIx"]="rtmp://192.168.28.125:1935/live/cdtf-MTNhYmIx"
["rtsp://36.133.66.40:8554/cdtf-ZTgzZDY3"]="rtmp://192.168.28.125:1935/live/cdtf-ZTgzZDY3"
["rtsp://36.133.66.40:8554/cdtf-YzczMmVj"]="rtmp://192.168.28.125:1935/live/cdtf-YzczMmVj"
["rtsp://36.133.66.40:8554/cdtf-M2RhMTE4"]="rtmp://192.168.28.125:1935/live/cdtf-M2RhMTE4"
["rtsp://36.133.66.40:8554/cdtf-ZTBhNzA2"]="rtmp://192.168.28.125:1935/live/cdtf-ZTBhNzA2"
["rtsp://36.133.66.40:8554/cdtf-MzFlOTE2"]="rtmp://192.168.28.125:1935/live/cdtf-MzFlOTE2"
["rtsp://36.133.66.40:8554/cdtf-YjNjNzAx"]="rtmp://192.168.28.125:1935/live/cdtf-YjNjNzAx"
["rtsp://36.133.66.40:8554/cdtf-MjE3Y2Rj"]="rtmp://192.168.28.125:1935/live/cdtf-MjE3Y2Rj"
["rtsp://36.133.66.40:8554/cdtf-NjZkYmZm"]="rtmp://192.168.28.125:1935/live/cdtf-NjZkYmZm"
["rtsp://36.133.66.40:8554/cdtf-ZTZkY2Y0"]="rtmp://192.168.28.125:1935/live/cdtf-ZTZkY2Y0"
["rtsp://36.133.66.40:8554/cdtf-MDg0ZTNi"]="rtmp://192.168.28.125:1935/live/cdtf-MDg0ZTNi"
["rtsp://36.133.66.40:8554/cdtf-MGIzZWI3"]="rtmp://192.168.28.125:1935/live/cdtf-MGIzZWI3"
["rtsp://36.133.66.40:8554/cdtf-MTc1ZTM5"]="rtmp://192.168.28.125:1935/live/cdtf-MTc1ZTM5"
["rtsp://36.133.66.40:8554/cdtf-MDVlYWZh"]="rtmp://192.168.28.125:1935/live/cdtf-MDVlYWZh"
["rtsp://36.133.66.40:8554/cdtf-NGJkZWJi"]="rtmp://192.168.28.125:1935/live/cdtf-NGJkZWJi"
["rtsp://36.133.66.40:8554/cdtf-YjgwYTY0"]="rtmp://192.168.28.125:1935/live/cdtf-YjgwYTY0"
["rtsp://36.133.66.40:8554/cdtf-YzE2Y2Q5"]="rtmp://192.168.28.125:1935/live/cdtf-YzE2Y2Q5"
["rtsp://36.133.66.40:8554/cdtf-YmZjMTM0"]="rtmp://192.168.28.125:1935/live/cdtf-YmZjMTM0"
["rtsp://36.133.66.40:8554/cdtf-ZGEyMzAw"]="rtmp://192.168.28.125:1935/live/cdtf-ZGEyMzAw"
["rtsp://36.133.66.40:8554/cdtf-NmM5YjYw"]="rtmp://192.168.28.125:1935/live/cdtf-NmM5YjYw"
["rtsp://36.133.66.40:8554/cdtf-NDJjNjg1"]="rtmp://192.168.28.125:1935/live/cdtf-NDJjNjg1"
["rtsp://36.133.66.40:8554/cdtf-ZjZhMDE4"]="rtmp://192.168.28.125:1935/live/cdtf-ZjZhMDE4"
["rtsp://36.133.66.40:8554/cdtf-ZDQ4YjY0"]="rtmp://192.168.28.125:1935/live/cdtf-ZDQ4YjY0"
["rtsp://36.133.66.40:8554/cdtf-YzgzZDE2"]="rtmp://192.168.28.125:1935/live/cdtf-YzgzZDE2"
["rtsp://36.133.66.40:8554/cdtf-ZGRiMDMx"]="rtmp://192.168.28.125:1935/live/cdtf-ZGRiMDMx"
["rtsp://36.133.66.40:8554/cdtf-NTM0MDUy"]="rtmp://192.168.28.125:1935/live/cdtf-NTM0MDUy"
["rtsp://36.133.66.40:8554/cdtf-ZGFkNjJj"]="rtmp://192.168.28.125:1935/live/cdtf-ZGFkNjJj"
["rtsp://36.133.66.40:8554/cdtf-NzU3NjZj"]="rtmp://192.168.28.125:1935/live/cdtf-NzU3NjZj"
["rtsp://36.133.66.40:8554/cdtf-OGM2ZWMx"]="rtmp://192.168.28.125:1935/live/cdtf-OGM2ZWMx"
["rtsp://36.133.66.40:8554/cdtf-MzQzNDJm"]="rtmp://192.168.28.125:1935/live/cdtf-MzQzNDJm"
["rtsp://36.133.66.40:8554/cdtf-NTBhMGRh"]="rtmp://192.168.28.125:1935/live/cdtf-NTBhMGRh"
["rtsp://36.133.66.40:8554/cdtf-MjkxZTFl"]="rtmp://192.168.28.125:1935/live/cdtf-MjkxZTFl"
["rtsp://36.133.66.40:8554/cdtf-ZWM3Zjg3"]="rtmp://192.168.28.125:1935/live/cdtf-ZWM3Zjg3"
["rtsp://36.133.66.40:8554/cdtf-YmU3N2Qw"]="rtmp://192.168.28.125:1935/live/cdtf-YmU3N2Qw"
["rtsp://36.133.66.40:8554/cdtf-ZTllNTNk"]="rtmp://192.168.28.125:1935/live/cdtf-ZTllNTNk"
["rtsp://36.133.66.40:8554/cdtf-YWJjMDg1"]="rtmp://192.168.28.125:1935/live/cdtf-YWJjMDg1"
["rtsp://36.133.66.40:8554/cdtf-M2JlYWEy"]="rtmp://192.168.28.125:1935/live/cdtf-M2JlYWEy"
["rtsp://36.133.66.40:8554/cdtf-YTBmNjJh"]="rtmp://192.168.28.125:1935/live/cdtf-YTBmNjJh"
["rtsp://36.133.66.40:8554/cdtf-YmYyZjdl"]="rtmp://192.168.28.125:1935/live/cdtf-YmYyZjdl"
["rtsp://36.133.66.40:8554/cdtf-ZjY0Zjdi"]="rtmp://192.168.28.125:1935/live/cdtf-ZjY0Zjdi"
["rtsp://36.133.66.40:8554/cdtf-ZDA5ZThk"]="rtmp://192.168.28.125:1935/live/cdtf-ZDA5ZThk"
["rtsp://36.133.66.40:8554/cdtf-YzkwYWRj"]="rtmp://192.168.28.125:1935/live/cdtf-YzkwYWRj"
["rtsp://36.133.66.40:8554/cdtf-ODA3M2E3"]="rtmp://192.168.28.125:1935/live/cdtf-ODA3M2E3"
["rtsp://36.133.66.40:8554/cdtf-ZDg4NGFi"]="rtmp://192.168.28.125:1935/live/cdtf-ZDg4NGFi"
["rtsp://36.133.66.40:8554/cdtf-OWJhNmMy"]="rtmp://192.168.28.125:1935/live/cdtf-OWJhNmMy"
["rtsp://36.133.66.40:8554/cdtf-YzBkYWVk"]="rtmp://192.168.28.125:1935/live/cdtf-YzBkYWVk"
["rtsp://36.133.66.40:8554/cdtf-YmVhY2I0"]="rtmp://192.168.28.125:1935/live/cdtf-YmVhY2I0"
["rtsp://36.133.66.40:8554/cdtf-OTFkODVl"]="rtmp://192.168.28.125:1935/live/cdtf-OTFkODVl"
["rtsp://36.133.66.40:8554/cdtf-MjI5MDY1"]="rtmp://192.168.28.125:1935/live/cdtf-MjI5MDY1"
["rtsp://36.133.66.40:8554/cdtf-MjBjZDU1"]="rtmp://192.168.28.125:1935/live/cdtf-MjBjZDU1"
["rtsp://36.133.66.40:8554/cdtf-Mzc0OWRm"]="rtmp://192.168.28.125:1935/live/cdtf-Mzc0OWRm"
["rtsp://36.133.66.40:8554/cdtf-NjVhOGVi"]="rtmp://192.168.28.125:1935/live/cdtf-NjVhOGVi"
["rtsp://36.133.66.40:8554/cdtf-YzVhMzE3"]="rtmp://192.168.28.125:1935/live/cdtf-YzVhMzE3"
["rtsp://36.133.66.40:8554/cdtf-YWIyNDZi"]="rtmp://192.168.28.125:1935/live/cdtf-YWIyNDZi"
["rtsp://36.133.66.40:8554/cdtf-MGExMGM4"]="rtmp://192.168.28.125:1935/live/cdtf-MGExMGM4"
["rtsp://36.133.66.40:8554/cdtf-NjVkYmY5"]="rtmp://192.168.28.125:1935/live/cdtf-NjVkYmY5"
["rtsp://36.133.66.40:8554/cdtf-MWU5NTRm"]="rtmp://192.168.28.125:1935/live/cdtf-MWU5NTRm"
["rtsp://36.133.66.40:8554/cdtf-YTA0NDMw"]="rtmp://192.168.28.125:1935/live/cdtf-YTA0NDMw"
["rtsp://36.133.66.40:8554/cdtf-MDQ2MWE1"]="rtmp://192.168.28.125:1935/live/cdtf-MDQ2MWE1"
["rtsp://36.133.66.40:8554/cdtf-YjE2MDNj"]="rtmp://192.168.28.125:1935/live/cdtf-YjE2MDNj"
["rtsp://36.133.66.40:8554/cdtf-M2FjYjcw"]="rtmp://192.168.28.125:1935/live/cdtf-M2FjYjcw"
["rtsp://36.133.66.40:8554/cdtf-OWZjZGFj"]="rtmp://192.168.28.125:1935/live/cdtf-OWZjZGFj"
["rtsp://36.133.66.40:8554/cdtf-M2VhOWNi"]="rtmp://192.168.28.125:1935/live/cdtf-M2VhOWNi"
)

# 遍历每个 RTSP 源
for src in "${!streams[@]}"; do
    # 使用 ffmpeg 将 RTSP 拉流并推送到对应的 RTMP 地址
    #ffmpeg -re -rtsp_transport tcp -i "$src" -f flv -r 15 -vcodec libx264 -preset ultrafast -vprofile baseline -an -s 800x600 -q 10 "${streams[$src]}" &
    ffmpeg -rtsp_transport tcp -i "$src"  -c:v libx264 -f flv "${streams[$src]}" &
done
